{% extends "v1/base.html" %}
{% block content %}
  
  {% for item in data  %}
        {% if item['show'] %}      
            <div id="{{ item['key'] }}" class="data"></div>
            <!-- 时间轴单位-{{ item['value'] }}-->
            <script type="text/javascript">
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById("{{ item['key'] }}"));  
                
                function randomData() {
                    return Math.round(Math.random()*1000);
                }
                
                var dateStr = "{{ item['x'] }}";
                var xAxisList = dateStr.split(';');
                var xAxisData = [];

                xAxisList.forEach(function (element) {
                    xAxisData.push(element);
                });
                                
                option = {
                    title: {
                        text: '放款金额(万)-{{ item['value'] }}',
                        size:10
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            crossStyle: {
                                color: '#999'
                            }
                        }
                    },
                    toolbox: {
                        feature: {
                            dataView: {show: true, readOnly: false},
                            magicType: {show: true, type: ['line', 'bar']},
                            restore: {show: true},
                            saveAsImage: {show: true}
                        }
                    },
                    legend: {
                        data:['放款金额','件均放款','累计件均放款']
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: xAxisData,
                            axisPointer: {
                                type: 'shadow'
                            }
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            name: '金额',
                            min: 0,
                            max: 1.3*{{ item['loan_x_max'] }},
                            interval: parseInt({{ item['loan_x_max'] }}/5),
                            axisLabel: {
                                formatter: '{value} 万'
                            }
                        },
                        {
                            type: 'value',
                            name: '金额',
                            min: 0,
                            max: 1.3*{{ item['loan_y_max'] }},
                            interval: parseInt({{ item['loan_y_max'] }}/5),
                            axisLabel: {
                                formatter: '{value} 万'
                            }
                        }
                    ],
                    series: [
                        {
                            name:'放款金额',
                            type:'bar',
                            data:{{ item['loan_amount'] }}
                        },
                        {
                            name:'件均放款',
                            type:'line',
                            yAxisIndex: 1,
                            data:{{ item['per_amount'] }}
                        },
                        {
                            name:'累计件均放款',
                            type:'line',
                            yAxisIndex: 1,
                            data:{{ item['per_his_amount'] }}
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。  
                myChart.setOption(option);   
            </script>
        {% endif  %}   
   {% endfor %}
   

{% endblock %}